import request from '@/utils/request'


export default {
  // openidlogin() {
  //   return request({
  //     url: '/openid/login',
  //     method: 'get',
  //   })
  // },
  //获取用户相关接口
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        username: searchModel.username,
        phone: searchModel.phone
      }
    })
  },
  addUser(user) {
    return request({
      url: '/user',
      method: 'post',
      data: user
    })
  },
  updateUser(user) {
    return request({
      url: '/user',
      method: 'put',
      data: user
    })
  },
  saveUser(user) {
    if (user.id == null || user.id == undefined) {
      return this.addUser(user);
    }
    return this.updateUser(user);
  },
  getUserById(id) {
    return request({
      // url: '/user' + id,
      url: `/user/${id}`,
      method: 'get',
    })
  },
  deleteUserById(id) {
    return request({
      // url: '/user' + id,
      url: `/user/${id}`,
      method: 'delete',
    })
  },
  
  //获取部门相关接口
  getDepList(searchModel) {
    return request({
      url: `/user/dep`,
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        // username: searchModel.username,
        // phone: searchModel.phone
      }
    })
  },
  getDepById(id) {
    return request({
      url: `/user/dep/${id}`,
      method: 'get',
    })
  },
  addDep(dep) {
    return request({
      url: '/user/dep',
      method: 'post',
      data: dep
    })
  },
  updateDep(dep) {
    return request({
      url: '/user/dep',
      method: 'put',
      data: dep
    })
  },
  saveDep(dep) {
    if (dep.id == null || dep.id == undefined) {
      return this.addDep(dep);
    }
    return this.updateDep(dep);
  },
  deleteDepById(id) {
    return request({
      // url: '/user' + id,
      url: `/user/dep/${id}`,
      method: 'delete',
    })
  },
  //
}
